#include <jni.h>
#include <stdio.h>

//
#include <android/log.h>
#define LOG_TAG "testjni_cpp"
#define LOGE(a) __android_log_write(ANDROID_LOG_ERROR,LOG_TAG,a)

void putStringNative(JNIEnv *env, jobject obj, jstring string);
jstring getStringNative(JNIEnv *env, jobject obj);


JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved){
    JNIEnv *env = NULL;
    JNINativeMethod NM[]={
        {"putString","(Ljava/lang/String;)V",(void*)putStringNative},
        {"getString","()Ljava/lang/String;",(void*)getStringNative}
    };

    jclass cls;

    if(vm->GetEnv((void**)&env,JNI_VERSION_1_4)!=JNI_OK){
        return JNI_ERR;
    }

    cls = env->FindClass("com/misoo/test/TestJni");

    env->RegisterNatives(cls,NM,2);
    return JNI_VERSION_1_4;
} 

void putStringNative(JNIEnv *env, jobject obj, jstring string){
    LOGE("langx putStringNative");
    return;
}

jstring getStringNative(JNIEnv *env, jobject obj){
    LOGE("langx getStringNative");
    return env->NewStringUTF("the string from c++");
}










